<?php
$db = new PDO("mysql:dbname=weike;host=192.168.0.88", "root", "123456");

$sql = "SELECT * FROM `weike_trade` WHERE `id` = ? LIMIT 1 ";
$args = ['555'];
$stmt = $db->prepare($sql);
// $stmt->bindValue(1, 'wcg_hkd');  
// $stmt->bindValue(2, '1');  
$stmt->execute($args);  
$rows = $stmt->fetch();  
$row_count = $stmt->rowCount(); //记录数，2  
print_r($rows);  
print_r($row_count);



$sql = "SELECT * FROM `weike_trade` WHERE `market` = ? AND `type` = ? AND `userid` > 0 AND `status` = 0 ORDER BY `price` desc,`id` asc ";
$args = [$market, $type];
$stmt = $db->prepare($sql);
$stmt->execute($args);
$stmt->fetchALL();

$sql = "SELECT * FROM `weike_trade` WHERE `id` = ? LIMIT 1 ";
$args = [$id];
$stmt = $db->prepare($sql);
$stmt->execute($args);
$stmt->fetch();



// $pdo->beginTransaction();//开启事务处理  
  
// try{  
//     //PDO预处理以及执行语句...  
      
//     $pdo->commit();//提交事务  
// }catch(PDOException $e){  
//     $pdo->rollBack();//事务回滚  
      
//     //相关错误处理  
//     throw $e;  
// }  